﻿using AyaWo.Commen;
using AyaWo.ToDo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace AyaWoWinSer
{
    public class ServiceDo
    {
        public void DoT()
        {
            try
            {
                //实例化Timer类  
                System.Timers.Timer Timer1 = new System.Timers.Timer();
                // 调用本方法开始用计算器            
                // Timer1.Interval = 1000 * 60;//测试 
                var tt = DatHelper<double>.GetDat("Hz.dat");
                if (tt == 0)
                    tt = 12;
                Timer1.Interval = 1000 * 60 * tt;//设置时钟周期为1秒（1000毫秒） 
                Log.Info($"Timer1.Interval：{Timer1.Interval}");
                Timer1.Elapsed += new ElapsedEventHandler(Timer1_Tick);
                Timer1.AutoReset = true;//执行一次 false，一直执行true // Enable timer.  
                Timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                Log.Error("DoT error: " + ex.Message + "");
            }
        }

        /// <summary>
        /// 运行程序的代码
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void Timer1_Tick(object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                ToDoSerVice.Initiali();
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
        }
    }
}
